package com.atguigu.tingshu.search.api;

import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.search.service.ItemService;
import com.atguigu.tingshu.search.service.SearchService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Tag(name = "专辑详情管理")
@RestController
@RequestMapping("api/search/albumInfo")
@SuppressWarnings({"all"})
public class itemApiController {

	@Autowired
	private ItemService itemService;
	@Autowired
	private SearchService searchService;

	/**
	 * 获取频道页数据
	 * @param categoryId
	 * @return
	 */
	@Operation(summary = "获取频道页数据")
	@GetMapping("/channel/{categoroy1Id}")
	public Result<List<Map<String, Object>>> channel(@PathVariable Long categoroy1Id) {
		List<Map<String, Object>>channelMap = searchService.channel(categoroy1Id);
		return Result.ok(channelMap);
	}

	@Operation(summary = "根据专辑Id 获取详情数据")
	@GetMapping("{albumId}")
	public Result getAlbumInfo(@PathVariable Long albumId) {

		Map<String, Object> AlbumInfo = itemService.getAlbumInfo(albumId);

		return Result.ok(AlbumInfo);
	}
}

